#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QPixmap>
#include <QDateTime>
#include "constants.h"
#include "mainscene.h"
#include "currentpointwidget.h"
#include "trackpointwidget.h"
#include "waypointwidget.h"
#include "geocaching.h"
#include "addpointdialog.h"
#include "editpointdialog.h"
#include "pointlistform.h"
#include "addroutedialog.h"
#include "routelistform.h"
#include "createmapdialog.h"
#include "editmapdialog.h"
#include "maplistform.h"
#include "tracklistform.h"
#include "createtrackdialog.h"
#include "setupgpsdialog.h"
#include "aboutdialog.h"

// Класс главного окна приложения.

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QApplication*, Geocaching*, QWidget *parent = 0);
    ~MainWindow();
private:
    double transformx(double m[8], double x, double y);
    double transformy(double m[8], double x, double y);
    void UpdateSize(void);

    Ui::MainWindow *ui;
    QApplication *myApp;
    Geocaching *myProg;

    // строка состояния
    QLabel *gpsStatusLabel, *gpsCoordLabel, *myCoordLabel, *trackLabel;

    // формы
    PointListForm   *plForm;
    RouteListForm   *rlForm;
    MapListForm     *mlForm;
    TrackListForm   *tlForm;

    // карта
    QPoint currentCursorPos;
    MainScene mainwindowScene;

    // объекты карты
    QList <QGraphicsLineItem*> currentRouteLines;
    QList <TrackPointWidget*> currentTrackPointList;
    QList <QGraphicsLineItem*> currentTrackLines;
    QList <WayPointWidget*> mainWayPointList;
    CurrentPointWidget *mainCurrentPoint;

    bool pointVisibility, routeVisibility, trackVisibility, currPointVisibility;
private slots:
    void AddPointDialogShow(void);
    void EditPointDialogShow(const unsigned long& = 0);
    void PointListFormShow(void);

    void AddRouteDialogShow(void) const;
    void RouteListFormShow(void);

    void CreateMapDialogShow(void);
    void EditMapDialogShow(void);
    void CloseMap(void);
    void DeleteMap(void);
    void MapListFormShow(void);

    void TrackListFormShow(void);
    void AutoRecordTrack(void);
    void StopAutoTrackDialogShow(const bool& = true);
    void ManualRecordTrack(void);
    void AddManualTrackPoint(void);
    void StopManualTrackDialogShow(const bool& = true);

    void SwitchGPS(void);
    void SetupGPSShow(void);

    void HelpShow(void) const;
    void AboutShow(void) const;

    void AddWayPoint(const Point&);
    void EditWayPoint(const Point&);
    void DeleteWayPoint(const unsigned long&);
    void UpdateCurrentRoute(void);
    void UpdateCurrentTrack(void);

    void SetCurrPointVisible(const bool&);
    void SetAllRouteVisible(const bool&);
    void SetAllWayPointVisible(const bool&);
    void SetAllTrackPointVisible(const bool&);

    void UpdateCursorPosition(QPoint Pos);
    void UpdateTrackStatus(void);
    void UpdateGPSStatus(void);
    void UpdateCurrentMap(void);
};

#endif // MAINWINDOW_H
